﻿/// <reference path="_namespace.js" />
/// <reference path="Window.js" />

/*****************************************************************************
Ajax library class definition. Kevin Robinson 2006.
Class: ajax.windows.FlyoutWindow
/*****************************************************************************/


ajax.lang.addNamespace("ajax.windows");

//-----------------------------------------------------------------------------
ajax.windows.FlyoutWindow = function(doc, sLayerName, w, h, parentNode) // Constructor
{                    
    ajax.windows.FlyoutWindow.superConstructor.call(this, doc, sLayerName, w, h, parentNode);
    
	// Properties
	this.layerOffsetX		= 0;
	this.layerOffsetY		= 0;
	this.animated			= false;
	this.currentWidth		= 0;
	this.currentHeight		= 0;
	this.expandStep			= 16;
	this.expanding			= false;	
}

//-----------------------------------------------------------------------------
ajax.lang.extend("ajax.windows.FlyoutWindow", "ajax.windows.Window"); // Inherit

//-----------------------------------------------------------------------------
ajax.windows.FlyoutWindow.prototype.expandWindow = function()
{
	this.expanding = false;
	if (this.currentWidth < this.width)		
	{
		this.expanding = true;
		this.currentWidth += this.expandStep;
	}
		
	if (this.currentHeight < this.height)
	{
		this.expanding = true;
		this.currentHeight += this.expandStep;
	}
	
	this.layer.style.width 	= this.currentWidth + "px";
	this.layer.style.height	= this.currentHeight + "px";
			
	if (!this.expanding)
		return;		
};

//-----------------------------------------------------------------------------
ajax.windows.FlyoutWindow.prototype.beginExpand = function()
{
	this.currentWidth			= 0;
	this.currentHeight			= 0;
	this.layer.style.width		= this.currentWidth;
	this.layer.style.height		= this.currentHeight;
	this.expanding = true;	
	
	this.expand();					
};

//-----------------------------------------------------------------------------
ajax.windows.FlyoutWindow.prototype.expand = function()
{	   
	if (!this.expanding)
		return;
	this.expandWindow();
	var oThis = this;
	setTimeout(function(){oThis.expand.call(oThis)}, 1);		
};

//-----------------------------------------------------------------------------
ajax.windows.FlyoutWindow.prototype.show = function(x, y, parentEle, event)
{	
    // Call the default show method..	    	    	      
    ajax.windows.FlyoutWindow.superClass.show.call(this, x, y, parentEle, event);
	// And animate if needed...
	if (this.animated)
		this.beginExpand();	
};

//-----------------------------------------------------------------------------
ajax.windows.FlyoutWindow.prototype.toString = function()
{
    return "ajax.windows.FlyoutWindow";
}

//-----------------------------------------------------------------------------
ajax.windows.FlyoutWindow.prototype.toClassName = function()
{
    return ajax.lang.getClassName("ajax.windows.FlyoutWindow");
}

//-----------------------------------------------------------------------------
ajax.windows.FlyoutWindow.cast = function(obj)
{///<returns type="ajax.windows.FlyoutWindow"/>
    return obj;
}